package com.yuexunit.operationman.nbsy.module.OperationInventory.adapter;

import android.content.Intent;
import android.view.View;
import android.widget.AbsListView;

import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.module.OperationInventory.bean.TempletBean;
import com.yuexunit.operationman.nbsy.module.OperationInventory.ui.Act_OperationInventory_SelectTemplet;
import com.yuexunit.operationman.nbsy.module.OperationInventory.ui.Act_OperationInventory_Templet;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.Collection;

/**
 * Created by work-jx on 2017/9/4.
 */
public class TempletAdapter extends KJAdapter<TempletBean.ObjectEntity> {
    private Act_OperationInventory_Templet aty;
    public TempletAdapter(AbsListView view, Collection<TempletBean.ObjectEntity> mDatas, int itemLayoutId,Act_OperationInventory_Templet aty) {
        super(view, mDatas, itemLayoutId);
        this.aty = aty;
    }

    @Override
    public void convert(AdapterHolder adapterHolder, final TempletBean.ObjectEntity item, boolean isScrolling, final int position) {
        adapterHolder.setText(R.id.item_operationinventory_templet_tv,item.getTempleName());

        onPicClick(adapterHolder.getConvertView(), item.getGoodsTempleId());
    }


    private void onPicClick(View view, final int goodsTempleId) {
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(aty, Act_OperationInventory_SelectTemplet.class);
                intent.putExtra("type","2");
                intent.putExtra("id", goodsTempleId);
                mCxt.startActivity(intent);
                aty.finish();

            }
        });
    }
}
